package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add("hello world");
        c.add("good moring");
        c.add("adadda");
        System.out.println("c"+c);


        Collection c1 = new ArrayList();
        c1.add("你好");
        c1.add("再见");
        System.out.println("c1:"+c1);



        c.addAll(c1);
        System.out.println("c1:"+c1);
        System.out.println("c:"+c);


        Collection c2 = new ArrayList();
        c2.add("你好");
        c2.add("拜拜");
        System.out.println("c2:"+c2);

        boolean collection = c1.containsAll(c2);//判断c1是否包含c2
        System.out.println("是否包含："+collection);//false

        /*
        //取交集：c1中仅保留与c2所共有的元素，而c2不变
        c1.retainAll(c2);
        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);
         */

        //删交集：将c1中与c2所共有的元素删掉，而c2不变
        c1.removeAll(c2);
        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);






































    }
}
